package com.deer.wms.base.system.service.task.impl;

import com.deer.wms.base.system.dao.task.TaskInfoHistoryMapper;
import com.deer.wms.base.system.model.task.*;
import com.deer.wms.base.system.model.ware.CellInfo;
import com.deer.wms.base.system.service.task.TaskInfoHistoryService;
import com.deer.wms.base.system.service.ware.ICellInfoService;
import com.deer.wms.common.core.service.AbstractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class TaskInfoHistoryServiceImpl extends AbstractService<TaskInfoHistory, Integer> implements TaskInfoHistoryService {
   @Autowired
   private TaskInfoHistoryMapper taskInfoHistoryMapper;

   @Autowired
   private ICellInfoService cellInfoService;

    @Override
    public int saveTaskInfoHistory(TaskInfo taskInfo) {
        return taskInfoHistoryMapper.saveTaskInfoHistory(taskInfo);
    }

    @Override
    public List<TaskInfoHistoryDto> findList(TaskInfoCriteria criteria) {
        return taskInfoHistoryMapper.findList(criteria);
    }

    @Override
    public TaskInfoHistoryDto verifTaskInfoHistory(TaskInfoCriteria criteria) {
        return taskInfoHistoryMapper.verifTaskInfoHistory(criteria);
    }

    @Override
    public List<TaskInfoDto> billInFindList(TaskInfoCriteria criteria) {
        return taskInfoHistoryMapper.billInFindList(criteria);
    }

    @Override
    public List<TaskInfoDto> billOutfindList(TaskInfoCriteria criteria) {
        return taskInfoHistoryMapper.billOutfindList(criteria);
    }

    @Override
    public List<TaskInfoHistoryDto> moveTaskHistory(TaskInfoCriteria taskInfoCriteria) {
        List<TaskInfoHistoryDto> list = taskInfoHistoryMapper.moveTaskHistory(taskInfoCriteria);
        for (TaskInfoHistoryDto taskInfoDto : list) {
            Integer moveAimCid = taskInfoDto.getMoveAimCid();
            CellInfo cellInfo = cellInfoService.selectCellInfoById(moveAimCid);
            if (null != cellInfo){
                String memo = cellInfo.getMemo();
                taskInfoDto.setMoveTaskAimCell(memo);
            }
        }
        return list;
    }
}

